#include "formakaoqin.h"
#include "ui_formakaoqin.h"
#include<QMessageBox>
#include<QSqlDatabase>
#include<QSqlQueryModel>
#include"admin.h"

FormAkaoqin::FormAkaoqin(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FormAkaoqin)
{
    ui->setupUi(this);
}

FormAkaoqin::~FormAkaoqin()
{
    delete ui;
}

void FormAkaoqin::showaw()
{
    Admin *aw = new Admin;
    aw->show();
    aw->selectBoxSlot(str);
}

void FormAkaoqin::showformakaoqin()
{
    emit signalformakaoqin();
    this->show();
}

void FormAkaoqin::on_pb_checkin_ok_clicked()
{
    QSqlQueryModel *model1 = new QSqlQueryModel(ui->tableView_checkin);
        if(ui->lineEdit_checkin_classid->text() == "all")
        {
             model1->setQuery(QString("select * from CheckinInfoTable;"));
         }else{
            model1->setQuery(QString("select * from CheckinInfoTable where Classid = '%1';").arg(ui->lineEdit_checkin_classid->text()));
        }
    //列名
    model1->setHeaderData(0, Qt::Horizontal, tr("XID"));
    model1->setHeaderData(1, Qt::Horizontal, tr("ScienceID"));
    model1->setHeaderData(2, Qt::Horizontal, tr("teacherId"));
    model1->setHeaderData(3, Qt::Horizontal, tr("Classid"));
    model1->setHeaderData(4, Qt::Horizontal, tr("RoomID"));
    model1->setHeaderData(6, Qt::Horizontal, tr("xuehao"));
    model1->setHeaderData(5, Qt::Horizontal, tr("CheckinTime"));

    ui->tableView_checkin->setModel(model1);//数据放置进去
    ui->tableView_checkin->verticalHeader()->hide();//不显示序号
}

void FormAkaoqin::on_pushButton_cancle_clicked()
{
    this->close();
    this->showaw();
}
